<?php
/*
 * @Author: lokei
 * @Date: 2022-09-18 13:16:51
 * @LastEditors: lokei
 * @LastEditTime: 2023-05-30 23:26:13
 * @Description: 
 */
namespace App\Http\Controllers\Store\Consignee;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Store\StoreModel;
use Illuminate\Http\Request;

class ConsigneeController extends Controller {
    public function get(Request $request) {
        $store = StoreModel::where('id', '=', $request->input('store_id'))->first();
        $res = ResultTool::success();
        $res['data'] = [
            'consignee_prov' => $store->consignee_prov,
            'consignee_city' => $store->consignee_city,
            'consignee_district' => $store->consignee_district,
            'consignee_address' => $store->consignee_address,
            'consignee_name' => $store->consignee_name,
            'consignee_mobile' => $store->consignee_mobile,
            'consignee_note' => $store->consignee_note,
            'name' => $store->name,
            'lng' => $store->lng,
            'lat' => $store->lat
        ];
        return $res;
    }

    public function set(Request $request) {
        $store = StoreModel::where('id', '=', $request->input('store_id'))->first();
        $store->consignee_prov = $request->input('consignee_prov');
        $store->consignee_city = $request->input('consignee_city');
        $store->consignee_district = $request->input('consignee_district');
        $store->consignee_address = $request->input('consignee_address');
        $store->consignee_name = $request->input('consignee_name');
        $store->consignee_mobile = $request->input('consignee_mobile');
        $store->consignee_note = $request->input('consignee_note');
        $store->save();
        return ResultTool::success();
    }
}